<?php
/**
 * Created by PhpStorm.
 * User: User
 * Date: 2017/9/29
 * Time: 8:15
 */

namespace php;


class personal
{
public $name;
public $age;
public $sex;

public function __construct($name,$age,$sex)
{
    $this->name=$name;
    $this->age=$age;
    $this->sex=$sex;
}

    public function say(){
   echo '我的名字是'.$this->name.'<br>我的性别是'.$this->sex.'<br>我的年龄是'.$this->age;

}
 public function  _set($name,$value){
        if($name=='age'){
            $this->age=(($value<0)?1:$value);

        }
        $this->name=$value;
 }
}

$my=new personal('大哥',26,'男');

$my->say();
$my->age=-40;
$my->say();
